package MapDemo;

import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.Set;

public class Mapkey {
    public static void main(String[] args) {
        HashMap<String, String> hm = new HashMap<String, String>();
        //添加元素
        System.out.println(hm.put("暴强", "荣荣"));
        System.out.println(hm.put("小强", "大荣"));
        System.out.println(hm.put("大枪", "笑容"));
        System.out.println(hm);
        //遍历
        Set<String> keys = hm.keySet();
        //通过健找值
        for (String key : keys) {
            String value = hm.get(key);
            System.out.println("老公:" + key + "----" + "媳妇:" + value);
        }
    }
}
